package shark.picture.controller;


import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author jianxin.wei
 * @description
 * @date 2025/4/25 13:20
 */
public class M {
    public static void main(String[] args) {
        List<Long> list = new ArrayList<>();

//        for (int i = 0; i < 10; i++) {
//            list.add(Math.round(Math.random() * 1000));
//        }
//        System.out.println(list);

        list = Arrays.asList(807L, 800L, 173L, 310L, 161L, 646L, 767L, 557L, 615L, 899L);

        System.out.println(algorithm1(list));


    }

    private static List<Long> algorithm1(List<Long> list) {
        for (int i = 0; i < list.size(); i++) {
            for (int j = 0; j < list.size() - 1; j++) {
                Long l1 = list.get(j);
                Long l2 = list.get(j + 1);
                if (l1 > l2) {
                    list.set(j, l2);
                    list.set(j + 1, l1);
                }
            }
        }
        return list;
    }

//    private static List<Long> algorithm2(List<Long> list) {
//
//    }

    private static void quickSort(List<Long> list, int left, int right) {
        if (left < right) {
            int pivot = partition(list, left, right);

            quickSort(list, left, pivot - 1);
            quickSort(list , pivot + 1 , right);
        }
    }

    private static int partition(List<Long> list, int left, int right) {
        long value = list.get(left);

        int i = left + 1 ;

        for (int j = left + 1; j <= right; j++) {
            if (list.get(j) < value){
                long temp = list.get(i);
                list.set(i, list.get(j));
                list.set(j, temp);
                i++;
            }
        }



        return 1;
    }

}
